<?php

class user{
	const sessid	= '$feeduid';



	public function in($uid){
		$_SESSION[self::sessid]	= $uid;
		return false;	
	}


	public function out(){
		session_unregister(self::sessid);
		return false;	
	}

	public function id(){
		$id	= $_SESSION[self::sessid];
		$id || $id =1;
		return $id;	
	}

	public function path(){
		$id	= $this->id();
		$dir	= ceil($id/1000);
		$path	= "data/".$dir."/";
		if( !file_exists($path) ){
			mkdir($path, 0755);
		}
		$path	= "data/".$dir."/$id";
		if( !file_exists($path) ){
			mkdir($path, 0755);
		}
		return $path;
	}



	public function &db(){
		return D::$db;	
	}


	public function &tpl(){
		$tpl	= new tpl();
		$tpl->assign('uid', $this->id() );
		$tpl->assign('upath', $this->path() );
		return $tpl;
	}


	public function isLogined(){
		return  !empty($_SESSION[self::sessid]);
	}


}
?>